{extend name="../index/public/mlay" /}
{block name="title"}Vip推广页面{/block}
{block name="style"}
<style>
	.qrcode {
		width: 8rem;
		margin: 0 auto;
		display: block;
	}
</style>
{/block}
{block name="header"}
{include file="public/header" /}
{/block}
{block name="container"}
{eq name="$user.auth" value="0"}
<div class="line-div bgn"></div>
<div class="weui-msg">
	 <div class="weui-msg__icon-area"><i class="weui-icon-warn weui-icon_msg"></i></div>
	<div class="weui-msg__text-area">
		<h2 class="weui-msg__title">暂未获得权限</h2>
		<p class="weui-msg__desc">请实名认证后，联系管理员开通</p>
	</div>
</div>
{else/}
<div class="line-div bgn"></div>
<div class="weui-msg">
	<div class="weui-msg__icon-area"><img class="qrcode" src="{$info.qrcode}" /></div>
	<div class="weui-msg__text-area">
		<p class="weui-msg__desc small">推广码（ID）：{$user.id}</p>
	</div>
	<div class="weui-msg__tips-area">
	  <p class="weui-msg__tips">由用户扫码建立推广关系，或点击右上角“…”，选择“发送给朋友”，将该页面分享给好友！</p>
	</div>
</div>

{/eq}
{/block}
{block name="copyright"}{/block}
{block name="script"}
<script>
	$(document).ready(function() {
		$("#to-post").on("click", function() {
			var data = {
				realname: $("input[name='realname']").val(),
				mobile: $("input[name='mobile']").val(),
				idcard: $("input[name='idcard']").val(),
				address: $("input[name='address']").val(),
				pid: $("input[name='pid']").val(),
				__token__: $("input[name='__token__']").val(),
			}
			$.post('', data, function(res) {
				if (res.code == 0) {
					weui.topTips(res.msg, {
						className: 'warning'
					});
				} else {
					weui.topTips(res.msg, {
						className: 'success'
					});
					var golink = function() {
						window.location.href = res.url;
					}
					setTimeout(golink, 500);
				}
			})
		})
		$("#openid").on("click", function() {
			$.post("{:url('api/index/getopenid')}", '', function(res) {
				if (res.code == 0) {
					weui.topTips(res.msg, {
						className: 'warning'
					});
				} else {
					weui.topTips(res.msg, {
						className: 'success'
					});
					$("input[name='address']").val(res.data);
				}
			});
		})
	})
</script>
{/block}
